#include "vetor.hpp"
#include "raio.hpp"
#include "esfera.hpp"
#include "plano.hpp"
#include "cena.hpp"
#include "raycaster.hpp"
#include "grade.hpp"
#include "luz.hpp"
#include "cor.hpp"
#include "material.hpp"
#include "objeto.hpp"
#define ALTURA 800
#define LARGURA 800

double x=0.0f,y=0.0,z=1.0;

Material* m1 = new Material(Cor(1.0,0.0,0.0),Cor(1.0,0.0,0.0),Cor(1.0,1.0,1.0),50);
Material* m2 = new Material(Cor(0.0,1.0,0.0),Cor(0.0,1.0,0.0),Cor(1.0,1.0,1.0),50);
Material* m3 = new Material(Cor(0.0,0.0,1.0),Cor(0.0,0.0,1.0),Cor(1.0,1.0,1.0),50);
Material* m4 = new Material(Cor(0.01,0.01,0.01),Cor(0.2,0.2,0.2),Cor(1,1,1),50);

Material* m5 = new Material(Cor(0.0,0.0,0.5),Cor(0.0,0.0,0.5),Cor(1.0,1.0,1.0),100);
Material* m6 = new Material(Cor(0.001,0.001,0.001),Cor(0.001,0.001,0.001),Cor(0.001,0.001,0.001),100);

Objeto* e1 = new Esfera(m1,Vetor(0.0,1.0,-2.0),0.5);
Objeto* e2 = new Esfera(m2,Vetor(-1.0,0.0,-2.0),0.5);
Objeto* e3 = new Esfera(m2,Vetor(1.0,0.0,-2.0),0.5);
Objeto* e4 = new Esfera(m4,Vetor(0.0,0.0,-4.0),1.5);

Objeto* p1 = new Plano(m6,Vetor(0.0,0.0,-2.0),Vetor(0.0,0.0,1.0));
Objeto* p2 = new Plano(m6,Vetor(0.0,0.0,2.0),Vetor(0.0,0.0,-1.0));
Objeto* p3 = new Plano(m6,Vetor(0.75,0.0,0.0),Vetor(-1.0,0.0,0.0));
Objeto* p4 = new Plano(m6,Vetor(-0.75,0.0,0.0),Vetor(1.0,0.0,0.0));
Objeto* p5 = new Plano(m6,Vetor(0.0,1.0,0.0),Vetor(0.0,-1.0,0.0));
Objeto* p6 = new Plano(m6,Vetor(0.0,-1.0,0.0),Vetor(0.0,1.0,0.0));

Luz* luz1 = new Luz(Vetor(0.0,0.0,-1.0),Vetor(0.0,1.0,1.0),
		Cor(1.0,1.0,1.0),
		Cor(1.0,1.0,1.0),
		Cor(1.0,1.0,1.0)
		);
Luz* luz2 = new Luz(Vetor(-1.0,-1.0,1.0),Vetor(1.0,0.0,1.0),
		Cor(1.0,1.0,1.0),
		Cor(1.0,1.0,1.0),
		Cor(1.0,1.0,1.0)
		);

Cena* c = new Cena(Cor(0.0,0.0,0.0));

Grade* g = new Grade(Vetor(1.0,0.0,0.0),Vetor(0.0,1.0,0.0),Vetor(0.0,0.0,0.0));

	Raycaster* r = new Raycaster(c,g,Vetor(0.0,0.0,2.0),Vetor(0.0,1.0,0.0),ALTURA,LARGURA,7);



int main(int argc, char** argv) {
	Tga* arquivo;
	c->setAtenuacao(0.01,0.01,1.0);
	c->addLuz(luz1);
/*	c->addObjeto(e1);
	c->addObjeto(e2);
	c->addObjeto(e3);
	c->addObjeto(e4);*/
	c->addObjeto(p1);
	c->addObjeto(p2);
	c->addObjeto(p3);
	c->addObjeto(p4);
	c->addObjeto(p5);
	c->addObjeto(p6);
//	c->addLuz(luz2);
	/*Esfera* esf;
	for(int i=0;i < 3;i++) {
		double x = -1+(((double) i));
		for(int j =0;j<3;j++) {
			double y = -1+(((double) j));
			esf = new Esfera(m2,Vetor(0.5*x,0.5*y,-2.0),0.15);
			if(i==1 && j ==1) { 
				esf = new Esfera(m1,Vetor(0.5*x,0.5*y,-2.0),0.15);
			}
			if(i%2 == 0 && j%2 == 0)
				esf = new Esfera(m3,Vetor(0.5*x,0.5*y,-2.0),0.15);
			c->addObjeto(esf);
		}
	}*/
	Esfera* teste = new Esfera(m3,Vetor(0.0,0.0,-2.0),0.25);
	c->addObjeto(teste);
	arquivo = r->cast();
	arquivo->salvarArquivo("teste.tga");

} 















